<html>
    <head>
        <style>
            body {
                padding: 0;
                margin: 0;
            }

            #box {
                width: 300px;
                height: 100px;
                position: absolute;
                top: 200px;
                left: 50%;
            }

            #button {
                position: absolute;
                inset: 0;
                background-color: #00cc88;
            }

            #trigger-overflow {
                width: 1px;
                height: 1px;
                position: absolute;
                top: 2000px;
                left: 2000px;
            }

            [data-layout-correct="false"] {
                background: #dd1144 !important;
                opacity: 0.5;
            }
        </style>
    </head>
    <body>
        <div id="box"><div id="button"></div></div>
        <div id="trigger-overflow"></div>

        <script type="module" src="/src/imports/projection.js"></script>
        <script type="module" src="/src/imports/script-assert.js"></script>
        <script type="module" src="/src/imports/script-undo.js"></script>
        <script type="module">
            const { createNode } = window.Undo
            const { matchViewportBox, addPageScroll } = window.Assert
            const { frame } = window.Projection
            const box = document.getElementById("box")
            const boxProjection = createNode(box)

            const button = document.getElementById("button")
            const buttonProjection = createNode(button, boxProjection)

            const scrollDistance = 100

            window.scrollTo(scrollDistance, scrollDistance)
            boxProjection.setValue("scale", 2)
            boxProjection.options.visualElement.render()

            const boxOrigin = box.getBoundingClientRect()
            const buttonOrigin = button.getBoundingClientRect()

            requestAnimationFrame(() => {
                buttonProjection.willUpdate()
                boxProjection.willUpdate()

                boxProjection.root.didUpdate()

                matchViewportBox(box, boxOrigin)
                matchViewportBox(button, buttonOrigin)
            })
        </script>
    </body>
</html>
